package cn.ruituo.web;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;

/**
 * @author oldliu
 * @since 1.0
 */
@Controller
@RequestMapping("ruituo")
public class HelloController {

    @RequestMapping("sayHi")
    public String sayHello(HttpServletRequest request){
        request.setAttribute("msg","hello，我是渣渣灰");

        return "forward:/welcome.jsp";
    }
    //
    @RequestMapping("login")
    public ModelAndView login(String uname, String upass, HttpSession s){
        //request.setAttribute("msg","hello，我是渣渣灰");
        //StandardServletMultipartResolver
        ModelAndView mv=new ModelAndView();
        //System.out.println(upass.substring(12));
        if("admin".equals(uname)&&"123".equals(upass)){
            s.setAttribute("USER_LOGIN",uname);
            mv.addObject("msg","登录成功");
            mv.setViewName("forward:/loginsucc.jsp");
        }else{
            mv.addObject("msg","错误的用户名或者密码！");
            mv.setViewName("forward:/login.jsp");
        }
        return mv;
    }
}
